using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;

namespace XbmcConnect
{
	internal class PlayerProxy
	{
		private string address;
		private string username;
		private string password;
		
		internal PlayerProxy(string address, string username, string password)
		{
			this.address = address;
			this.username = username;
			this.password = password;
		}
		
		internal PlayerGetActivePlayersResponseResult GetActivePlayers()
		{
			PlayerGetActivePlayersRequest request = new PlayerGetActivePlayersRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "Player.GetActivePlayers";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(PlayerGetActivePlayersRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(PlayerGetActivePlayersResponse));
				PlayerGetActivePlayersResponse response = (PlayerGetActivePlayersResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}
	}
	
	internal class AudioPlayerProxy
	{
		private string address;
		private string username;
		private string password;
		
		internal AudioPlayerProxy(string address, string username, string password)
		{
			this.address = address;
			this.username = username;
			this.password = password;
		}
		
		internal AudioPlayerStateResponseResult State()
		{
			AudioPlayerStateRequest request = new AudioPlayerStateRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.State";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerStateRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerStateResponse));
				AudioPlayerStateResponse response = (AudioPlayerStateResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal AudioPlayerPlayPauseResponseResult PlayPause()
		{
			AudioPlayerPlayPauseRequest request = new AudioPlayerPlayPauseRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.PlayPause";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerPlayPauseRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerPlayPauseResponse));
				AudioPlayerPlayPauseResponse response = (AudioPlayerPlayPauseResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal void Stop()
		{
			AudioPlayerStopRequest request = new AudioPlayerStopRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.Stop";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerStopRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void SkipPrevious()
		{
			AudioPlayerSkipPreviousRequest request = new AudioPlayerSkipPreviousRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.SkipPrevious";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerSkipPreviousRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void SkipNext()
		{
			AudioPlayerSkipNextRequest request = new AudioPlayerSkipNextRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.SkipNext ";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerSkipNextRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void BigSkipBackward()
		{
			AudioPlayerBigSkipBackwardRequest request = new AudioPlayerBigSkipBackwardRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.BigSkipBackward";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerBigSkipBackwardRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void BigSkipForward()
		{
			AudioPlayerBigSkipForwardRequest request = new AudioPlayerBigSkipForwardRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.BigSkipForward";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerBigSkipForwardRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void SmallSkipBackward()
		{
			AudioPlayerSmallSkipBackwardRequest request = new AudioPlayerSmallSkipBackwardRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.SmallSkipBackward";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerSmallSkipBackwardRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void SmallSkipForward()
		{
			AudioPlayerSmallSkipForwardRequest request = new AudioPlayerSmallSkipForwardRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.SmallSkipForward";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerSmallSkipForwardRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Rewind()
		{
			AudioPlayerRewindRequest request = new AudioPlayerRewindRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.Rewind";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerRewindRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Forward()
		{
			AudioPlayerForwardRequest request = new AudioPlayerForwardRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.Forward ";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerForwardRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal AudioPlayerGetTimeResponseResult GetTime()
		{
			AudioPlayerGetTimeRequest request = new AudioPlayerGetTimeRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.GetTime";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerGetTimeRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerGetTimeResponse));
				AudioPlayerGetTimeResponse response = (AudioPlayerGetTimeResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal int GetPercentage()
		{
			AudioPlayerGetPercentageRequest request = new AudioPlayerGetPercentageRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.GetPercentage";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerGetPercentageRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerGetPercentageResponse));
				AudioPlayerGetPercentageResponse response = (AudioPlayerGetPercentageResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal void SeekTime(int parameter)
		{
			AudioPlayerSeekTimeRequest request = new AudioPlayerSeekTimeRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioPlayer.SeekTime";
			request.Parameter = parameter;
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerSeekTimeRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
			using (MemoryStream stream = new MemoryStream())
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioPlayerSeekTimeResponse));
			}
	
	
		}
	}
	
	internal class AudioLibraryProxy
	{
		private string address;
		private string username;
		private string password;
		
		internal AudioLibraryProxy(string address, string username, string password)
		{
			this.address = address;
			this.username = username;
			this.password = password;
		}
		
		internal void GetArtists()
		{
			AudioLibraryGetArtistsRequest request = new AudioLibraryGetArtistsRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioLibrary.GetArtists";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioLibraryGetArtistsRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void ScanForContent()
		{
			AudioLibraryScanForContentRequest request = new AudioLibraryScanForContentRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "AudioLibrary.ScanForContent";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AudioLibraryScanForContentRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}
	}
	
	internal class VideoLibraryProxy
	{
		private string address;
		private string username;
		private string password;
		
		internal VideoLibraryProxy(string address, string username, string password)
		{
			this.address = address;
			this.username = username;
			this.password = password;
		}
		
		internal VideoLibraryGetMoviesResponseResult GetMovies(string fields, string sortmethod, string sortorder, int start, int end)
		{
			VideoLibraryGetMoviesRequest request = new VideoLibraryGetMoviesRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "VideoLibrary.GetMovies";

			VideoLibraryGetMoviesRequestParameters parameters = new VideoLibraryGetMoviesRequestParameters();
			parameters.fields = fields;
			parameters.sortmethod = sortmethod;
			parameters.sortorder = sortorder;
			parameters.start = start;
			parameters.end = end;

			request.Parameters = parameters;
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(VideoLibraryGetMoviesRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(VideoLibraryGetMoviesResponse));
				VideoLibraryGetMoviesResponse response = (VideoLibraryGetMoviesResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal VideoLibraryGetRecentlyAddedMoviesResponseResult GetRecentlyAddedMovies(string fields, string sortmethod, string sortorder, int start, int end)
		{
			VideoLibraryGetRecentlyAddedMoviesRequest request = new VideoLibraryGetRecentlyAddedMoviesRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "VideoLibrary.GetRecentlyAddedMovies";

			VideoLibraryGetRecentlyAddedMoviesRequestParameters parameters = new VideoLibraryGetRecentlyAddedMoviesRequestParameters();
			parameters.fields = fields;
			parameters.sortmethod = sortmethod;
			parameters.sortorder = sortorder;
			parameters.start = start;
			parameters.end = end;

			request.Parameters = parameters;
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(VideoLibraryGetRecentlyAddedMoviesRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(VideoLibraryGetRecentlyAddedMoviesResponse));
				VideoLibraryGetRecentlyAddedMoviesResponse response = (VideoLibraryGetRecentlyAddedMoviesResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal void ScanForContent()
		{
			VideoLibraryScanForContentRequest request = new VideoLibraryScanForContentRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "VideoLibrary.ScanForContent";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(VideoLibraryScanForContentRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}
	}
	
	internal class XbmcSystemProxy
	{
		private string address;
		private string username;
		private string password;
		
		internal XbmcSystemProxy(string address, string username, string password)
		{
			this.address = address;
			this.username = username;
			this.password = password;
		}
		
		internal void Shutdown()
		{
			XbmcSystemShutdownRequest request = new XbmcSystemShutdownRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "System.Shutdown";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemShutdownRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Suspend()
		{
			XbmcSystemSuspendRequest request = new XbmcSystemSuspendRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "System.Suspend";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemSuspendRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Hibernate()
		{
			XbmcSystemHibernateRequest request = new XbmcSystemHibernateRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "System.Hibernate";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemHibernateRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Reboot()
		{
			XbmcSystemRebootRequest request = new XbmcSystemRebootRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "System.Reboot";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemRebootRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Quit()
		{
			XbmcSystemQuitRequest request = new XbmcSystemQuitRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "XBMC.Quit";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemQuitRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal void Introspect()
		{
			XbmcSystemIntrospectRequest request = new XbmcSystemIntrospectRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "JSONRPC.Introspect";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemIntrospectRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
	
		}

		internal XbmcSystemVersionResponseResult Version()
		{
			XbmcSystemVersionRequest request = new XbmcSystemVersionRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "JSONRPC.Version";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemVersionRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemVersionResponse));
				XbmcSystemVersionResponse response = (XbmcSystemVersionResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal int GetVolume()
		{
			XbmcSystemGetVolumeRequest request = new XbmcSystemGetVolumeRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "XBMC.GetVolume";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemGetVolumeRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemGetVolumeResponse));
				XbmcSystemGetVolumeResponse response = (XbmcSystemGetVolumeResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}

		internal void SetVolume(int parameter)
		{
			XbmcSystemSetVolumeRequest request = new XbmcSystemSetVolumeRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "XBMC.SetVolume";
			request.Parameter = parameter;
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemSetVolumeRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
			using (MemoryStream stream = new MemoryStream())
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemSetVolumeResponse));
			}
	
	
		}

		internal string Ping()
		{
			XbmcSystemPingRequest request = new XbmcSystemPingRequest();
			request.JsonRpcVersion = "2.0";
			request.Method = "JSONRPC.Ping";
			
			byte[] requestData;
			using(MemoryStream stream = new MemoryStream())
			{
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemPingRequest));
				serializer.WriteObject(stream, request);
                requestData = stream.GetBuffer();
			}
		
			WebClient webClient = new WebClient();
			webClient.Credentials = new NetworkCredential(this.username, this.password);
		
			byte[] responseData = webClient.UploadData(this.address, requestData);
	
			using (MemoryStream stream = new MemoryStream(responseData))
            {
				DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(XbmcSystemPingResponse));
				XbmcSystemPingResponse response = (XbmcSystemPingResponse)serializer.ReadObject(stream);
				return response.Result;
			}
	
		}
	}
	
}